home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / tools / czesc_1 / easyprocess / source / launch / waitproc.c < prev    next >
C/C++ Source or Header  |  1992-09-07  |  1KB  |  61 lines

  1. #include <arpbase.h>
  2. #include <arp_proto.h>
  3. #include "Launch.h"
  4. #include "LaunchPriv.h"
  5.  
  6.  
  7. /*
  8.  *    NAME
  9.  *        WaitProcess -- wait for a particular process to end.
  10.  *
  11.  *    SYNOPSIS
  12.  *        WaitProcess (Proc)
  13.  *
  14.  *        void WaitProcess (struct Process *);
  15.  *
  16.  *    DESCRIPTION
  17.  *        Check if the process pair list exists, check if the child
  18.  *        process exists and if it's alive.  Wait until it dies and
  19.  *        remove the process pair from the list, free the parent signal
  20.  *        and free the memory.
  21.  *
  22.  *        Free the list if it's empty.
  23.  *
  24.  *    INPUT
  25.  *        Proc - the child process to be waiting upon.
  26.  *
  27.  *    OUTPUT
  28.  *        None.
  29.  *
  30.  *    NOTE
  31.  *        You MUST be the parent of the process !!!
  32.  *
  33.  *    HISTORY
  34.  *        1992/09/06    Pierre Baillargeon        Creation
  35.  *
  36.  *    SEE ALSO
  37.  *        WaitProcesses(), WaitProcFunc()
  38.  */
  39.  
  40. void WaitProcess (struct Process *Proc)
  41. {
  42.     struct ProcPair *pp;
  43.  
  44.     Forbid ();
  45.     if (ProcPairList)
  46.     {
  47.         if (pp = IsChild (Proc))
  48.         {
  49.             while (pp->pp_ChildEntry)
  50.             {
  51.                 Wait (1L << pp->pp_ParentBit | KILL_PROCESS_FLAG);
  52.             }
  53.             Remove (pp);
  54.             FreeParentSignal (pp->pp_ParentBit);
  55.             FreeMem (pp, sizeof (struct ProcPair));
  56.         }
  57.         FreeProcPairList ();
  58.     }
  59.     Permit ();
  60. }
  61.